package payroll.trans;

import java.util.LinkedHashMap;

import payroll.Employee;
import payroll.Paycheck;
import payroll.PayrollDatabase;
import payroll.Transaction;

import java.util.Map;
import java.util.LinkedHashMap;

public class PaydayTransaction implements Transaction{

    private Map<Integer, Paycheck> paychecks = new LinkedHashMap<>();

    @Override
    public void execute() {
        //为每个雇员 支付薪资
        for(Employee e : PayrollDatabase.listAllEmployee()) {
            //创建一个Paycheck
            Paycheck paycheck = new Paycheck();
            //计算工资并填写支付方式 到paycheck
            e.pay(paycheck); //根据计算工资的方式，支付方式，填写paycheck
            //保存paycheck
            paychecks.put(e.getEmpId(), paycheck);
        }
    }

    public Paycheck getPaycheckOf(int empId) {
        return paychecks.get(empId);
    }

}
